<?php
require_once ("../db/connectdatabase.php");
require_once ("../entitys/UuDai.php");

function insertUuDai($uudai) {
	$con = new ConnectDB();
	
	$tbl = "uudai";
	$fn = array('typeuudai' => ($uudai -> getLoaiUuDai()), 'tenuudai' => ($uudai -> getTenUuDai()), 'nameproduct' => ($uudai -> getTenSanPham()), 'infoview' => ($uudai -> getInfoBasic()), 'saleoff' => ($uudai -> getGiamGia()), 'ngaybatdau' => ($uudai -> getNgayBatDau()), 'ngayhethan' => ($uudai -> getNgayHetHan()), 'content' => ($uudai -> getNoiDung()), 'diachilienhe' => ($uudai -> getDiaChi()), 'bankid' => ($uudai -> getMaNganHang()), 'bankname' => ($uudai -> getTenNganHang()), 'banklogo' => ($uudai -> getLogoNganHang()), 'loaithe' => ($uudai -> getLoaiThe()), 'image' => ($uudai -> getImage()), 'datecreate' => ($uudai -> getDateUpdate()));
	return $con -> insert($tbl, $fn);
}

function updateUuDai($uudai) {
	$con = new ConnectDB();
	
	$tbl = "uudai";
	$fn = array('typeuudai' => ($uudai -> getLoaiUuDai()), 'tenuudai' => ($uudai -> getTenUuDai()), 'nameproduct' => ($uudai -> getTenSanPham()), 'infoview' => ($uudai -> getInfoBasic()), 'saleoff' => ($uudai -> getGiamGia()), 'ngaybatdau' => ($uudai -> getNgayBatDau()), 'ngayhethan' => ($uudai -> getNgayHetHan()), 'content' => ($uudai -> getNoiDung()), 'diachilienhe' => ($uudai -> getDiaChi()), 'bankid' => ($uudai -> getMaNganHang()), 'bankname' => ($uudai -> getTenNganHang()), 'banklogo' => ($uudai -> getLogoNganHang()), 'loaithe' => ($uudai -> getLoaiThe()), 'image' => ($uudai -> getImage()), 'datecreate' => ($uudai -> getDateUpdate()));
	$condition = array('iduudai' => ($uudai -> getID()));
	return $con -> update($tbl, $fn, $condition);
}

function deleteUuDai($id) {
	$con = new ConnectDB();
	
	$tbl = "uudai";
	$fn = array('isuse' => false);
	$condition = array('iduudai' => $id);
	return $con -> update($tbl, $fn, $condition);
}

function deleteUuDaiArray($arrid) {
	$con = new ConnectDB();
	
	$tbl = "uudai";
	$fn = array('isuse' => false);
	$idrowdel = "iduudai";
	$condition = $arrid;
	return $con -> updatedels($tbl, $fn, $idrowdel, $condition);
}


?>